/*
 * @Author: Aaron
 * @Date: 2022-02-18 17:33:08
 * @LastEditors: YanMeng
 * @LastEditTime: 2022-11-01 11:59:42
 * @Description: file content
 * @FilePath: \ias_ui\src\api\coi\onlineTaskAPI\spuEdit.js
 * @Company: 沃尔玛
 */
import request from '../../../utils/request.js'
import { exportFile } from '../../exportFile.js'
const prefix = process.env.VUE_APP_BASE_API11

const url = {
  getAlohaSpuByChannelList: `${prefix}/spu/spuInfo/aloha/getAlohaSpuByChannelList`,
  downloadWares: `${prefix}/spu/spuInfo/aloha/exportAlohaSpuByChannelList`,
  newDownloadWares: `${prefix}/spu/spuInfo/aloha/exportSpuChannelInfo`,
  getAlohaSpuAllList: `${prefix}/spu/spuInfo/aloha/getAlohaSpuAllList`,
  spuDownloadWares: `${prefix}/spu/spuInfo/aloha/exportAlohaSpuAllList`,
  releaseChannel: ``,
  getAllMainStatusTypes: `${prefix}/chgSpu/processStatus/getAllMainStatusTypes`,
  procurementList: `${prefix}/chgSpu/chgSpuInfo/getChgSpuInfoPageList`,
  textStrokeList: `${prefix}/chgSpu/chgSpuInfo/content/getChgSpuInfoPageList`,
  handleLog: `${prefix}/spu/spuInfo/aloha/getAlohaSpuOperationLogList`,
  getchgSpuDetailById: `${prefix}/chgSpu/chgSpuInfo/getChgSpuDetailById`,
  getChgSpuInfoBySpuCode: `${prefix}/chgSpu/chgSpuInfo/getChgSpuInfoBySpuCode`,
  saveChgSpuChannelInfo: `${prefix}/chgSpu/chgSpuInfo/saveChgSpuChannelInfo`,
  saveChgSpuContent: `${prefix}/chgSpu/chgSpuInfo/saveChgSpuContent`,
  setChgSpuChannelInfo: `${prefix}/chgSpu/chgSpuInfo/setChgSpuChannelInfo`,
  initChgSpu: `${prefix}/chgSpu/chgSpuInfo/initChgSpu`,
  initChgSpu1: `${prefix}/chgSpu/chgSpuInfo/initChangeSpu`,
  addChgSpuSkuMapping: `${prefix}/chgSpu/sku/addChgSpuSkuMapping`,
  deleteChgSpuSkuMapping: `${prefix}/chgSpu/sku/deleteChgSpuSkuMapping`,
  setChgSpuSeriesInfo: `${prefix}/chgSpu/chgSpuInfo/setChgSpuSeriesInfo`,
  setSpuSaleAttrSort: `${prefix}/chgSpu/chgSpuInfo/setChgSpuSaleAttrSort`,
  setChgSpuContent: `${prefix}/chgSpu/chgSpuInfo/setChgSpuContent`,
  // 图片资源
  uploadSpuResource: `${prefix}/chgSpu/resource/uploadChgSpuResource`,
  uploadSpuContentResource: `${prefix}/chgSpu/resource/uploadContentFile`,
  uploadSaleAttrValueResource: `${prefix}/chgSpu/resource/uploadSaleAttrValueResource`,
  deleteSpuResource: `${prefix}/chgSpu/resource/deleteChgSpuResource`,
  deleteSpuContentResource: `${prefix}/chgSpu/resource/deleteChgSpuContentResource`,
  deleteSaleAttrValueResource: `${prefix}/chgSpu/resource/deleteSaleAttrValueResource`,
  getProcessLogByChgSpuId: `${prefix}/chgSpu/processStatus/getProcessLogByChgSpuId`,
  abandonEditRequest: `${prefix}/chgSpu/chgSpuInfo/cancellation`,
  batchUpdateShopCategoryByChannel: `${prefix}/spu/spuInfo/aloha/batchUpdateShopCategoryByChannel`,
  spuSubmit_text: `${prefix}/chgSpu/chgSpuInfo/submit`,
  pushSpu_text: `${prefix}/chgSpu/chgSpuInfo/pushChgSpu`,
  withdrawEdit: `${prefix}/chgSpu/chgSpuInfo/withdraw`,
  getChgSkuAttr: `${prefix}/skuInfo/aloha/chgSpu/getChgSkuAttr`,
  updateChgSkuAttr: `${prefix}/skuInfo/aloha/chgSpu/updateChgSkuAttr`,
  pageSpuChannelInfo: `${prefix}/spu/spuInfo/aloha/pageSpuChannelInfo`,
  // 操作日志
  querySpuChanelInfoLogBySpuCode: `${prefix}/spu/spuInfo/aloha/querySpuChanelInfoLogBySpuCode`,
  // 获取销售属性
  querySpuSaleAttrInfo: `${prefix}/chgSpu/chgSpuInfo/getSaleAttrAndBindInfoByChgSpuId`,
  // 保存销售属性排序
  setSeriesAndSaleAttr: `${prefix}/chgSpu/chgSpuInfo/setSeriesAndSaleAttr`
}

// buy渠道列表
export const getAlohaSpuByChannelList = (data) => {
  const { getAlohaSpuByChannelList, pageSpuChannelInfo } = url
  return request({
    url: window.appConfig.hiddenNewProducts ? getAlohaSpuByChannelList : pageSpuChannelInfo,
    method: 'POST',
    data
  })
}

// 渠道导出
export const downloadWares = (data, name) => {
  const { downloadWares, newDownloadWares } = url
  return exportFile(window.appConfig.hiddenNewProducts ? downloadWares : newDownloadWares, data, name)
}

// 全渠道列表
export const getAlohaSpuAllList = (data) => {
  return request({
    url: url.getAlohaSpuAllList,
    method: 'POST',
    data
  })
}

// 全渠道导出
export const spuDownloadWares = (data, name) => {
  return exportFile(url.spuDownloadWares, data, name)
}

// 发布渠道
export const releaseChannel = (data) => {
  return request({
    url: url.releaseChannel,
    method: 'POST',
    data
  })
}
// 查询是否有日志
export const handleLog = (data) => {
  return request({
    url: url.handleLog,
    method: 'POST',
    data
  })
}

// 状态枚举
export const getAllMainStatusTypes = (data) => {
  return request({
    url: url.getAllMainStatusTypes,
    method: 'get',
    data
  })
}

// 采销任务列表
export const procurementList = (data) => {
  return request({
    url: url.procurementList,
    method: 'POST',
    data
  })
}

// 文描团队
export const textStrokeList = (data) => {
  return request({
    url: url.textStrokeList,
    method: 'POST',
    data
  })
}

// 发起spu修改
export const initChgSpu = (data, menuName, isModify) => {
  let urlPaths = url.initChgSpu
  console.log('isModify', isModify)
  if (menuName === 'JDWX' || isModify) urlPaths = url.initChgSpu1
  return request({
    method: 'post',
    url: urlPaths,
    data
  })
}

// 修改spu详情
export const getchgSpuDetailById = (params) => {
  return request({
    method: 'get',
    url: url.getchgSpuDetailById,
    params
  })
}

// spu详情中台
export const getChgSpuInfoBySpuCode = (params) => {
  return request({
    method: 'get',
    url: url.getChgSpuInfoBySpuCode,
    params
  })
}

// 保存渠道信息
export const saveChgSpuChannelInfo = (data) => {
  return request({
    method: 'post',
    url: url.saveChgSpuChannelInfo,
    data
  })
}

// 保存渠道信息(提交)
export const setChgSpuChannelInfo = (data) => {
  return request({
    method: 'post',
    url: url.setChgSpuChannelInfo,
    data
  })
}

// 保存渠道文描（文描团队）
export const saveChgSpuContent = (data) => {
  return request({
    method: 'post',
    url: url.saveChgSpuContent,
    data
  })
}

// 提交推送（文描团队）
export const setChgSpuContent = (data) => {
  return request({
    method: 'post',
    url: url.setChgSpuContent,
    data
  })
}

// spu编辑 sku映射
export const addChgSpuSkuMapping = (data) => {
  return request({
    method: 'post',
    url: url.addChgSpuSkuMapping,
    data
  })
}

// spu编辑 sku映射
export const deleteChgSpuSkuMapping = (params) => {
  return request({
    method: 'get',
    url: url.deleteChgSpuSkuMapping,
    params
  })
}

// spu编辑保存系列
export const setChgSpuSeriesInfo = (data) => {
  return request({
    method: 'post',
    url: url.setChgSpuSeriesInfo,
    data
  })
}

// 保存销售属性排序
export const setSpuSaleAttrSort = (data) => {
  return request({
    method: 'post',
    url: url.setSpuSaleAttrSort,
    data
  })
}

// spu图片上传
export const uploadSpuResource = (data) => {
  return request({
    method: 'PUT',
    url: url.uploadSpuResource,
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// spu销售属性图片上传
export const uploadSaleAttrValueResource = (data) => {
  return request({
    method: 'PUT',
    url: url.uploadSaleAttrValueResource,
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// spu文描图片上传
export const uploadSpuContentResource = (data) => {
  return request({
    method: 'PUT',
    url: url.uploadSpuContentResource,
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
}

// spu图片删除
export const deleteSpuResource = (data) => {
  return request({
    method: 'post',
    url: url.deleteSpuResource,
    data
  })
}

// spu销售属性图片删除
export const deleteSaleAttrValueResource = (data) => {
  return request({
    method: 'post',
    url: url.deleteSaleAttrValueResource,
    data
  })
}

// spu文描删除
export const deleteSpuContentResource = (data) => {
  return request({
    method: 'post',
    url: url.deleteSpuContentResource,
    data
  })
}

// 查看操作日志
export const getProcessLogByChgSpuId = (params) => {
  return request({
    method: 'get',
    url: url.getProcessLogByChgSpuId,
    params
  })
}

// 作废
export const abandonEditRequest = (data) => {
  return request({
    method: 'post',
    url: url.abandonEditRequest,
    data
  })
}

// spu渠道修改店内类目
export const batchUpdateShopCategoryByChannel = (data) => {
  return request({
    method: 'post',
    url: url.batchUpdateShopCategoryByChannel,
    data
  })
}

// spu提交
export const spuSubmit_text = (data) => {
  return request({
    method: 'post',
    url: url.spuSubmit_text,
    data
  })
}

// 推送
export const pushSpu_text = (data) => {
  return request({
    method: 'POST',
    url: url.pushSpu_text,
    data
  })
}

// 撤回
export const withdraw_edit = (data) => {
  return request({
    method: 'post',
    url: url.withdrawEdit,
    data
  })
}

// 获取sku下沉属性
export const getChgSkuAttr = (data) => {
  return request({
    method: 'post',
    url: url.getChgSkuAttr,
    data
  })
}

// 保存sku下沉属性
export const updateChgSkuAttr = (data) => {
  return request({
    method: 'post',
    url: url.updateChgSkuAttr,
    data
  })
}

// 操作日志
export const handleLogTos = (data) => {
  return request({
    method: 'post',
    url: url.querySpuChanelInfoLogBySpuCode,
    data
  })
}

// 根据spucode查询销售属性
export const getSalesAttributes = (data) => {
  return request({
    method: 'post',
    url: url.querySpuSaleAttrInfo,
    data: data || 12
  })
}

// 保存spu销售属性
export const setSeriesAndSaleAttr = (data) => {
  return request({
    method: 'post',
    url: url.setSeriesAndSaleAttr,
    data
  })
}
